/*
 * CS_MATCH_TIME_OVER.cpp
 *
 *  Created on: 2013. 10. 1.
 *      Author: mega@gamevil.com
 */

#include "../../Command.h"
#include "../../User.h"
#include "../../NLogic/Party.h"

namespace ProjectZ { namespace NCommand {

void Command::CS_MATCH_TIME_OVER(User * pUser, ::Network::Packet * pPacket)
{
	/*
	 * PVP 대전에서 상대가 수락/거절 전에 접속 종료한 경우
	 * CS_MATCH_TIME_OVER 패킷을 C->S로 전송한다
	 */

	PREPARE_PACKET;

	NLogic::Party * pParty = pUser->GetParty();
	if (NULL == pParty)
	{
		DEBUGLOG("CS_MATCH_TIME_OVER : pParty is NULL!!");
		return;
	}

	pParty->LeaveUser(pUser);

//	auto iter = pParty->GetAllUserTree().begin();
//
//	for ( ; iter != pParty->GetAllUserTree().end(); iter++)
//	{
//		pParty->LeaveUser(iter->second);
//	}


	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();

	*pAck << static_cast<int16_t>(ACK_MATCHING_FAIL);

	pAck->MakePacket(CMD_SC_MATCH_TIME_OVER);
	pUser->Send(pAck);
}

} /*NCommand*/ } /*ProjectZ*/
